﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Dados.ConexaoCE;
using System.Data.SqlServerCe;

namespace EFITransmissao.Dados.DAO
{
    public class DAOManutencao
    {
        public static void RepararDB()
        {            
            try
            {
                SqlCeEngine engine = new SqlCeEngine(@"Persist Security Info = false; 
                                   Data Source = .\Program Files\EFI_Sulgipe\Leituras.sdf");

                if (false == engine.Verify())
                {                    
                    engine.Repair(null, RepairOption.RecoverCorruptedRows);                 
                }
                
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return;
        }

        public static void CompactarDB()
        {
            try
            {
                SqlCeEngine engine = new SqlCeEngine(@"Persist Security Info = false; 
                                   Data Source = .\Program Files\EFI_Sulgipe\Leituras.sdf");

                engine.Shrink();

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return;
        }

    }
}
